// 单独出来的模块，需要注册到index里
import { asyncRoutes, constantRoutes } from '@/router/index'
const state = {
  routes: []
}
const mutations = {
  setRoutes(state, routes) {
    state.routes = [...constantRoutes, ...routes]
  }
}
const actions = {
  async routesFilter(store, menus) {
    // 路由筛选
    const routes = await asyncRoutes.filter(route => menus.includes(route.name))
    store.commit('setRoutes', routes)
    return routes
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
